home *** CD-ROM | disk | FTP | other *** search
- // AKUA Protos OneFile
- /////////////////////////////
- //
- // Includes Beg
- //
- #define STANDALONER TRUE
-
- #include "yLibCfg.h"
-
- #include "Reaper.h"
-
- #ifndef _yDragH
- #include "yDrag.h"
- #endif // _yDragH
-
- #ifndef _yDrawH
- #include "yDraw.h"
- #endif // _yDrawH
-
- #ifndef _yGlobalH
- #include "yGlobal.h"
- #endif // _yGlobalH
-
- #ifndef _yMemoryH
- #include "yMemory.h"
- #endif // _yMemoryH
-
- #ifndef _yStringH
- #include "yString.h"
- #endif // _yStringH
-
-
- #include <Devices.h>
- //
- // Includes End
- //
- /////////////////////////////
-
- /*****************************************************************************************************************\
-
- File: cdev.c
-
- Version: 1.10
-
- Contains: 'OAGT' Object Agent for OdoClock
-
- Written by: Gregory Mathias Lemperle-Kerr
-
- Copyright: ©1992-1996 worldwide by AKUA Interactive Media, Inc. All rights reserved
-
- Usage: This file contains the code for an 'OAGT' that dynamically connects to
- the 'cdev' to handle the window object. Messages from the Finder are translated
- to standard window agent messages and passed on to the OAGT who may pass them
- on to panel object agents.
-
- To Do:
-
- History:
- 110 GOD 19.03.1997 Added speech
-
- 100 GOD 15.05.1996 Start
-
- \*****************************************************************************************************************/
-
-
- // AKUA Statics Beg
- oaVal main(oaObj windowObject);
- void waSmartTest(void);
- void waAppMenuAdd(ident id, StringPtr name, bool byName);
- void waAppMenuItemSet(short n, ident id, StringPtr name, bool byName);
- void waAppMenuUpdate(window w);
- void waAppIdxSet(window w, ident id, StringPtr name);
- int waAppIdxGet(window w);
- void waSettingsUpdate(window w);
- short waHeapToMenuVal(short heap);
- short waHeapMenuItemVal(short menuIdx);
- void waBitHit(window w, ident itemID, flag16 bit, appItem item);
- void wiMaxSet(window w, ident itemID, short val);
- void wiMaxSetI(wndObj itm, short val);
- void wiValSet(window w, ident itemID, short val);
- void wiValSetI(wndObj itm, short val);
- short wiValGet(window w, ident itemID);
- short wiValGetI(wndObj itm);
- void wiRedraw(window w, ident itemID);
- void wiRedrawI(drawPort dp, wndObj itm);
- void wiEnable(window w, ident itemID, bool onOff);
- void wiEnableI(drawPort dp, wndObj itm, bool onOff);
- void wiValUnset(wndObj item, bool onOff);
- bool wiValUnget(wndObj item);
- void wiTxtGetI(wndObj itm, StringPtr txt);
- void wiTxtSetI(wndObj itm, StringPtr txt);
- void wiTxtGet(window w, ident itemID, StringPtr txt);
- void wiTxtSet(window w, ident itemID, StringPtr txt);
- wndObj wiGet(window w, ident itemID);
- yError osErrorSet(yError err);
- void dpVariantChange(drawPort dp, byte newVariant);
- void dpVariantSet(drawPort dp, byte newVariant);
- byte dpVariantGet(drawPort dp);
- bool evUserCancel(void);
- KeyModFlag evModifiers(void);
- KeyModFlag evModConvert(flag16 sysMods);
- KeyModFlag evModsDown(void);
- void evKeysDown(StringPtr keys);
- bool evMods(KeyModFlag testThese);
- Handle rsGetOne(fileSpec file, ident classID);
- Handle rsGetOne(fileSpec file, ident classID, RsrcNumber resNum);
- oaVal rsGet1All(oAgent agt, oaObj obj, Handle * whereInObj, bool load);
- Handle rsGetX(fila family);
- Handle rsGet(ident resKind, ident resId);
- Handle rsGet1X(fila family);
- Handle rsGet1(ident myType, ident myIdent);
- Handle rsGet1Idx(ResType resClass, int wholeIdx);
- Handle rsGet1Num(ResType resClass, RsrcNumber resNum);
- Handle rsGet1NumDetach(ResType resClass, RsrcNumber resNum);
- Handle rsGetNum(ResType resClass, RsrcNumber resNum);
- Handle rsGetNumDetach(ResType resClass, RsrcNumber resNum);
- Handle rsGetIdx(ResType resClass, int wholeIdx);
- Handle rsGetIdxDetach(ResType resClass, int wholeIdx);
- Handle rsGet1IdxDetach(ResType resClass, int wholeIdx);
- Handle rsGet1Named(ident resKind, StringPtr name);
- Handle rsGetNamed(ident resKind, StringPtr name);
- Handle rsGetNamedDetach(ident resKind, StringPtr name);
- Handle rsGet1Random(ident resKind);
- Handle mmHdlNewClr(lwrd s);
- void mmBlkClr(void * p, long s);
- void mmBlkCpyCode(const void * p, void * q, long s);
- void mmBlkCpy(const void * p, void * q, long s);
- void mmBlkSwap(void * p, void * q, long s);
- yError mmHdlCpy(const void * srcHdl, void * dstHdl);
- yError mmHdlCpyAt(const void * srcHdl, register void * dstHdl, long where);
- yError mmHdlDup(const void * srcHdl, void * dstHdlPtr);
- yError mmHdlDupTmp(const void * srcHdl, register void * dstHdlPtr);
- void * mmHdlExtendLine(void * hdl, StringPtr line);
- void * mmHdlExtendClr(void * hdl, long cnt);
- StringPtr mmHdlExtend(void * hdl, long cnt);
- yError mmHdlSizeSetX(void * hdl, long newSize);
- StringPtr mmHdlExpandAt(void * hdl, void * where, long howManyBytes);
- yError mmHdlExpandX(void * hdl, void * where, long howManyBytes);
- yError mmHdlExpand(void * hdl, long where, long howManyBytes);
- HdlState mmHdlResizeBeg(const void * dataHdl);
- void mmHdlResizeEnd(const void * dataHdl, HdlState saveState);
- HdlState mmHdlWorkBegX(const void * dataHdl, bool longTerm);
- HdlState mmHdlWorkBeg(const void * dataHdl);
- void mmHdlWorkEnd(const void * dataHdl, HdlState saveState);
- bool mmHdlWorkStatic(const void * hdl);
- Ptr mmPtrNew(lwrd s);
- Ptr mmPtrNewClr(lwrd s);
- void msWaitBeg(void);
- void msWaitEnd(void);
- void msRotate(void);
- bool osProcessExists(long procID);
- bool osProcessTrapInstall(short * installCnt, ProcessNum *** installed, word trapWord, SysProc trapAdr, SysProc * jumpAdr);
- ident osProcessCurrentId(void);
- ProcessNum osProcessId(ProcessNum procNum, ident * creator, ProcessSN * psn);
- bool osProcessInFront(void);
- yError osProcessToFront(void);
- bool osProcessWasFront(ProcessSN * currentPSN);
- yError osProcessFind(ident appID, register ProcessSN * appSN);
- yError osProcessInfo(ProcessSN * appSN, ProcessInfoRec * appInfo);
- yError osProcessSetFront(ident appID);
- yError osProcessSetFrontSN(ProcessSN * psn);
- yError osProcessLaunch(ident appID, fileSpec specIfNoID, ProcessSN * appSN, AppParametersPtr parms, bool front, bool quit);
- yError osProcessSpec(ProcessNum procNum, fileSpec appSpec);
- yError osProcessFindOnDisk(ident appID, fileSpec appSpec);
- yError osProcessFindOnVol(ident appID, VolRef vRefNum, fileSpec appSpec);
- ProcessNum osProcessSpecToNum(fileSpec fs);
- void osProcessFirst(ProcessSN * appSN, ProcessInfoRec * appInfo, StringPtr name, fileSpec fs);
- yError osProcessNext(ProcessSN * appSN, ProcessInfoRec * appInfo, StringPtr name, ident creator, bool bgAlso);
- bool osProcessWaitForUser(int waitSecsBeforeForce);
- // AKUA Statics End
-
-
-
- enum PanelItemIDs
- {
- // Actions
- ipiImport = 'Get…',
- ipiRemove = 'Rmv!',
- ipiTest = 'Test',
- // Check Boxes
- ipiOnlyIfROM = 'ROM+',
- ipiByName = 'Nam+',
- ipiExpand = 'Exp+',
- ipiSmartHeap = 'SmH+',
- ipiLimitHeap = 'Lim+',
- ipiRun68K = '68K+',
- ipiFixFCB = 'FCB+',
- // Radio Buttons
- // Menus
- ipiApplication = 'App ',
- ipiHeap = 'Heap',
- // Text
- ipiCreator = 'AppC',
- ipiInfo = 'Info',
- ipiVersion = 'Vers',
- ipiAkua = 'AKUA',
- // Pictures
- ipiTitle = 'TITL',
- ipiBoxT = 'BoxT',
- ipiBoxL = 'BoxL',
- ipiBoxB = 'BoxB',
- ipiBoxR = 'BoxR',
- ipiDivider = 'BoxD'
- };
-
-
- enum PanelItemVals
- {
- kivHeapNoChange = 1,
- kivHeapDivider,
- kivHeapLowest,
-
- kivAppRWM = 1, // Default - all other apps
- kivAppROM, // all ROM apps
- kivAppZero, // Divider
- kivAppOne, // First "real" app
-
- // Menu IDs
- kmiHeap = -4064,
- kmiApplication = -4047
- };
-
-
- enum AlertNums
- {
- kalTest = -4059,
- kalTestWarn = -4058,
- kalTestGood = -4057,
- kalTestBad = -4056
- };
-
-
- // Assuming idx==1 means first app…
- #define mcPrefItem(pref, idx) ((pref)->item + ((idx) - kivAppOne))
- #define mcMenuItem(idx) ((idx) + kivAppZero)
-
-
-
- MonkeyFlag theMonkey = 0;
- FileRef swaHomeRef = 0;
- BADAPP thePrefs = NULL;
- MenuHandle swaAppMenu = NULL;
- MenuHandle swaHeapMenu = NULL;
- bool swaPrefsChanged = FALSE;
-
-
- oaVal main(oaObj windowObject)
- {
- EnterCodeRsrc();
-
- window w = (window)windowObject;
- oaVal retVal = noErr;
-
- switch(mcWdMsg(w))
- {
- case kwmIdle:
- if (swaPrefsChanged && thePrefs)
- {
- swaPrefsChanged = FALSE;
-
- if (rsFlush(thePrefs))
- SysBeep(11);
-
- // Update extension if running…
- long gest;
-
- if (!Gestalt(igsReaper, &gest))
- {
- reaperGlo gat = (reaperGlo)gest;
-
- if (gat->prefs && ((*gat->prefs)->version == (*thePrefs)->version))
- mmHdlCpy(thePrefs, gat->prefs);
- else
- {
- Str63 iText;
- wiTxtGet(w, ipiAkua, iText);
- wiTxtSet(w, ipiAkua, "\pOLDER REAPER IS INSTALLED.");
- Delay(30, (lwrd *)&gest);
- wiTxtSet(w, ipiAkua, iText);
- }
- }
- else
- {
- Str63 iText;
- wiTxtGet(w, ipiAkua, iText);
- wiTxtSet(w, ipiAkua, "\pTHE REAPER IS NOT INSTALLED.");
- Delay(30, (lwrd *)&gest);
- wiTxtSet(w, ipiAkua, iText);
- }
- }
- break;
-
-
- case kwmCtrlUp:
- if (BADAPP prefs = thePrefs)
- {
- msWaitBeg();
-
- switch (mcWdHit(w))
- {
- case ipiApplication:
- waSettingsUpdate(w);
- break;
-
- case ipiRemove:
- goto remove;
-
- case ipiTest:
- waSmartTest();
- break;
-
- default:
- {
- HdlState saveState = mmHdlWorkBeg(prefs);
- badApp pref = *prefs;
- int appIdx = waAppIdxGet(w);
- appItem item = (appIdx > 0) ? (pref->item + appIdx - 1) : NULL;
- short * reapP = item ? &item->reap :
- appIdx ? &pref->reapRWM : &pref->reapROM;
-
- flag16 bit = 0;
-
- switch (mcWdHit(w))
- {
- // Radios
- // Flags
- case ipiOnlyIfROM: bit = bbaOnlyIfROM; break;
- case ipiByName: bit = bbaByName; break;
- case ipiExpand: bit = bbaExpand; break;
- case ipiSmartHeap: bit = bbaSmartHeap; break;
- case ipiLimitHeap: bit = bbaLimitHeap; break;
- case ipiRun68K: bit = bbaRun68K; break;
- case ipiFixFCB: bit = bbaFixFCB; break;
-
- // Menus
- case ipiHeap:
- *reapP = waHeapMenuItemVal(mcWdHitVal(w));
- swaPrefsChanged = TRUE;
- break;
-
- default:
- SysBeep(11);
- break;
- }
-
- if (bit && item)
- waBitHit(w, mcWdHit(w), bit, item);
-
- mmHdlWorkEnd(prefs, saveState);
- }
- }
-
- msWaitEnd();
- }
- break;
-
-
- case kwmUpdate:
- if (!mcFlagTst(theMonkey, bEvMonkeyLives))
- {
- mcFlagSet(theMonkey, bEvMonkeyLives);
- // Initial drawing? Enable/Disable controls etc.
- waSettingsUpdate(w);
- }
- break;
-
-
- case kwmClear:
- remove: if (int appIdx = waAppIdxGet(w)) if (appIdx > 0) if (BADAPP prefs = thePrefs)
- if (!mmHdlExpandX(prefs, &(*prefs)->item[--appIdx], -sizeof(AppItem)))
- {
- DeleteMenuItem(swaAppMenu, appIdx + kivAppOne);
-
- if (appIdx == -- (*prefs)->cnt) // was last item
- wiValSet(w, ipiApplication, appIdx ? (appIdx + kivAppZero) : 1);
-
- stSlutSet(prefs, mcPrefSlutOffset(*prefs), appIdx + 1, NULL, FALSE);
-
- waAppMenuUpdate(w);
- waSettingsUpdate(w);
- swaPrefsChanged = TRUE;
- }
- break;
-
-
- case kwmDragInq:
- break;
-
-
- case kwmDragIn: // Current resFile may not be our home, so post the change
- {
- dragInfoItem item = mcDdDragInItem(w);
-
- switch(item->flavor)
- {
- case flavorTypeHFS:
- if (item->hfs.fileCreator == igsReaper)
- {
- if (Handle prefs = rsGetOne(&item->hfs.fileSpec, ircPreferences))
- {
- if (**(word **)prefs >= kvrReaperMinCompat)
- {
- mmHdlCpy(prefs, thePrefs);
-
- waAppMenuUpdate(w);
- wiValSet(w, ipiApplication, kivAppRWM);
- waSettingsUpdate(w);
-
- swaPrefsChanged = TRUE;
- }
-
- mmHdlDel(prefs);
-
- if (!swaPrefsChanged)
- goto beep;
- }
- else
- goto beep;
- }
- else
- {
- msWaitBeg();
-
- // Add to prefs or get its settings…
- if (Handle crap = rsGetOne(&item->hfs.fileSpec, ircSizeOfHeap))
- mmHdlDel(crap);
- else if (osProcessFindOnDisk(item->hfs.fileCreator, &item->hfs.fileSpec))
- {
- SysBeep(21);
- goto noAdd;
- }
-
- waAppIdxSet(w, item->hfs.fileCreator, item->hfs.fileSpec.name);
-
- noAdd: msWaitEnd();
- }
- break;
-
- default:
- beep: SysBeep(11);
- break;
- }
- }
- break;
-
-
- case kwmInit:
- msWaitBeg();
-
- swaHomeRef = CurResFile();
-
- if (!(thePrefs = (BADAPP)rsGet('PREF', igsReaper)))
- SysBeep(11);
-
- swaHeapMenu = GetMenu(kmiHeap);
-
- if (swaAppMenu = GetMenu(kmiApplication))
- waAppMenuUpdate(w);
-
- SetWTitle(mcWdPort(w), "\pThe Reaper by AKUA");
-
- msWaitEnd();
- break;
-
-
- case kwmQuit:
- break;
- }
-
- LeaveCodeRsrc();
- return retVal;
- }
-
-
-
- void waSmartTest(void)
- {
- Size tf = TempFreeMem();
- NoteAlert(kalTestGood, NULL);
- return;
-
- long ram;
- Handle crap;
- yError err;
-
- Gestalt(gestaltLogicalRAMSize, &ram);
-
- THz tmpZone = HandleZone(crap = TempNewHandle(9, &err));
-
- mmHdlDel(crap);
-
- if (((Ptr)tmpZone > osROMBase)
- || ((long)tmpZone > ram)
- || ((long)tmpZone < 0)
- || (tmpZone != osTwitchZone) )
- StopAlert(kalTestWarn, NULL);
- else
- {
- long diff = tf - tmpZone->zcbFree;
-
- if (diff < 0)
- diff = -diff;
-
- if ((tmpZone->zcbFree > ram) || (tmpZone->zcbFree < 0) || (diff > 0x10000L))
- CautionAlert(kalTestBad, NULL);
- else
- NoteAlert(kalTestGood, NULL);
- }
- }
-
-
-
- void waAppMenuAdd(ident id, StringPtr name, bool byName)
- {
- AppendMenu(swaAppMenu, "\pAkua");
- waAppMenuItemSet(CountMenuItems(swaAppMenu), id, name, byName);
- }
-
-
-
- void waAppMenuItemSet(short n, ident id, StringPtr name, bool byName)
- {
- Str63 itemName;
-
- stPtoP(name, itemName);
-
- itemName[++*itemName]= ' ';
- itemName[++*itemName]= byName ? '(' : '[';
- utIdToText(id, itemName + *itemName + 1);
- itemName[0] += sizeof(id);
- itemName[++*itemName]= byName ? ')' : ']';
-
- SetMenuItemText(swaAppMenu, n, itemName);
- }
-
-
-
- void waAppMenuUpdate(window w)
- {
- if (BADAPP prefs = thePrefs)
- {
- HdlState saveState = mmHdlWorkBeg(prefs);
- badApp pref = *prefs;
- int cnt = pref->cnt;
- int cmax = cnt;
- appItem item = pref->item;
- StringPtr name = mcSlutString(mcPrefSlutX(item, cnt));
-
- while(short n = CountMenuItems(swaAppMenu))
- DeleteMenuItem(swaAppMenu, n);
-
- AppendMenu(swaAppMenu, "\pDefaults;Read-Only Application;(-");
-
- for( ; cnt; cnt--, item ++, name += *name + 1)
- waAppMenuAdd(item->creator, name, mcObjBool(item, bbaByName));
-
- wiMaxSet(w, ipiApplication, cmax);
-
- mmHdlWorkEnd(prefs, saveState);
- }
- }
-
-
-
-
- void waAppIdxSet(window w, ident id, StringPtr name)
- {
- msWaitBeg();
-
- if (BADAPP prefs = thePrefs)
- {
- int appIdx;
- bool matchedName;
-
- appItem item = rpFindApp(prefs, id, name, TRUE, &appIdx, &matchedName);
-
- if (!item || !matchedName)
- {
- if (mmHdlExpand(prefs, mcPrefSlutOffset(*prefs), sizeof(AppItem)))
- {
- SysBeep(11);
- appIdx = 0;
- }
- else
- {
- badApp pref = *prefs;
-
- item = pref->item + pref->cnt;
-
- appIdx = ++ pref->cnt; // Added a new item
-
- item->creator = id;
- item->reap = -25; // 25% default?
- item->flags = 0;
-
- // Add name to list
- BreakStr(name);
- stSlutSet(prefs, mcPrefSlutOffset(*prefs), appIdx, name, FALSE);
-
- waAppMenuAdd(id, name, FALSE);
-
- swaPrefsChanged = TRUE;
- }
- }
-
- wiValSet(w, ipiApplication, appIdx + kivAppZero);
-
- waSettingsUpdate(w);
- }
-
- msWaitEnd();
- }
-
-
-
-
- int waAppIdxGet(window w)
- {
- int appIdx = wiValGet(w, ipiApplication);
-
- if (!appIdx)
- wiValSet(w, ipiApplication, appIdx = 1);
-
- // Cut off divider - first app is 1, 0 is default
- // 1 to -1, 2 to 0 for defaults
- return appIdx -= (appIdx > kivAppZero) ? kivAppZero : (kivAppZero - 1);
- }
-
-
-
-
- void waSettingsUpdate(window w)
- {
- msWaitBeg();
-
- if (BADAPP prefs = thePrefs)
- {
- // Get current settings
- short reap;
-
- int appIdx = waAppIdxGet(w);
- badApp pref = *prefs;
-
- wiEnable(w, ipiFixFCB, appIdx > 0);
- wiEnable(w, ipiRun68K, appIdx > 0);
- wiEnable(w, ipiLimitHeap, appIdx > 0);
- wiEnable(w, ipiSmartHeap, appIdx > 0);
- wiEnable(w, ipiExpand, appIdx > 0);
- wiEnable(w, ipiByName, appIdx > 0);
- wiEnable(w, ipiOnlyIfROM, appIdx > 0);
- wiEnable(w, ipiRemove, appIdx > 0);
-
- if (appIdx > 0)
- {
- appItem item = pref->item + appIdx - 1;
-
- // Check Boxes
- wiValSet(w, ipiFixFCB, mcObjBool(item, bbaFixFCB) );
- wiValSet(w, ipiRun68K, mcObjBool(item, bbaRun68K) );
- wiValSet(w, ipiLimitHeap, mcObjBool(item, bbaLimitHeap) );
- wiValSet(w, ipiSmartHeap, mcObjBool(item, bbaSmartHeap) );
- wiValSet(w, ipiExpand, mcObjBool(item, bbaExpand) );
- wiValSet(w, ipiByName, mcObjBool(item, bbaByName) );
- wiValSet(w, ipiOnlyIfROM, mcObjBool(item, bbaOnlyIfROM) );
-
- reap = item->reap;
- }
- else
- {
- wiValSet(w, ipiFixFCB, FALSE );
- wiValSet(w, ipiRun68K, FALSE );
- wiValSet(w, ipiLimitHeap, FALSE );
- wiValSet(w, ipiSmartHeap, FALSE );
- wiValSet(w, ipiExpand, FALSE );
- wiValSet(w, ipiByName, FALSE );
- wiValSet(w, ipiOnlyIfROM, FALSE );
- reap = appIdx ? pref->reapRWM : pref->reapROM;
- }
-
- // Heap Value
- wiValSet(w, ipiHeap, waHeapToMenuVal(reap));
- }
-
- msWaitEnd();
- }
-
-
-
-
- short waHeapToMenuVal(short heap)
- {
- if (!heap)
- return kivHeapNoChange;
-
- short bestItem = kivHeapLowest;
- short best = 0;
- int itemCnt = CountMenuItems(swaHeapMenu);
-
- for(int i = kivHeapLowest; (i <= itemCnt); i++)
- {
- if (short mval = waHeapMenuItemVal(i))
- {
- // %age?
- if ((heap < 0) && (mval < 0))
- {
- if ((mval >= heap) && (mval < best))
- {
- best = mval;
- bestItem = i;
- }
- }
- else if ((heap > 0) && (mval > 0))
- {
- if ((mval <= heap) && (mval > best))
- {
- best = mval;
- bestItem = i;
- }
- }
- }
- }
-
- return bestItem;
- }
-
-
-
- short waHeapMenuItemVal(short menuIdx)
- {
- Str63 iText;
-
- GetMenuItemText(swaHeapMenu, menuIdx, iText);
-
- // Divider?
- if (!iText[0] || (iText[1] == '-'))
- return 0;
-
- StringPtr valTxt = iText;
- int valLen = *valTxt++;
- long val = stParseValLong(&valTxt, &valLen); // Get number
-
- switch (*++valTxt)
- {
- case '%': val = -val; break;
-
- case 'k':
- case 'K': val >>= 4; break;
-
- case 'm':
- case 'M': val <<= 6; break;
- }
-
- return val;
- }
-
-
-
-
- void waBitHit(window w, ident itemID, flag16 bit, appItem item)
- {
- bool onOff = !wiValGet(w, itemID);
-
- wiValSet(w, itemID, onOff);
- mcObjTog(item, bit);
-
- if (itemID == ipiByName)
- {
- int appIdx = waAppIdxGet(w);
-
- if (appIdx > 0)
- {
- Str63 name;
- GetMenuItemText(swaAppMenu, appIdx + kivAppZero, name);
- stTransliterate(name + 1, *name, onOff ? "\p[" : "\p(", onOff ? "\p(" : "\p[");
- stTransliterate(name + 1, *name, onOff ? "\p]" : "\p)", onOff ? "\p)" : "\p]");
- SetMenuItemText(swaAppMenu, appIdx + kivAppZero, name);
- wiRedraw(w, ipiApplication);
- }
- }
-
- swaPrefsChanged = TRUE;
- }
-
-
-
-
- void wiMaxSet(window w, ident itemID, short val)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiMaxSetI(itm, val);
- }
-
-
-
- void wiMaxSetI(wndObj itm, short val)
- {
- if (mcWoIsCtl(itm))
- {
- if (val > (*mcWoCtlHdl(itm))->contrlMax)
- SetControlMaximum(mcWoCtlHdl(itm), val);
-
- InvalRect(&itm->bounds); // Silly System 8 pop-ups don't react
- }
- }
-
-
-
- void wiValSet(window w, ident itemID, short val)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiValSetI(itm, val);
- }
-
-
-
- void wiValSetI(wndObj itm, short val)
- {
- if (mcWoIsCtl(itm))
- {
- if (val > (*mcWoCtlHdl(itm))->contrlMax)
- SetControlMaximum(mcWoCtlHdl(itm), val);
-
- InvalRect(&itm->bounds); // Silly System 8 pop-ups don't react
- SetControlValue(mcWoCtlHdl(itm), val);
- }
- else if (mcWoHasTxt(itm))
- {
- Str15 tempest;
-
- stLongToStr(val, tempest);
- wiTxtSetI(itm, tempest);
- }
- }
-
-
-
- short wiValGet(window w, ident itemID)
- {
- if (wndObj itm = wiGet(w, itemID))
- return wiValGetI(itm);
-
- return 0;
- }
-
-
-
- short wiValGetI(wndObj itm)
- {
- if (mcWoIsCtl(itm))
- return GetControlValue(mcWoCtlHdl(itm));
- else if (mcWoHasTxt(itm))
- {
- Str31 tempest;
-
- wiTxtGetI(itm, tempest);
- return stValLong(tempest);
- }
-
- return 0;
- }
-
-
-
- void wiRedraw(window w, ident itemID)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiRedrawI(mcWdDrawPort(w), itm);
- }
-
-
-
- void wiRedrawI(drawPort dp, wndObj itm)
- {
- InvalRect(&itm->bounds); // Silly System 8 pop-ups don't react
- }
-
-
-
- void wiEnable(window w, ident itemID, bool onOff)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiEnableI(mcWdDrawPort(w), itm, onOff);
- }
-
-
-
- void wiEnableI(drawPort dp, wndObj itm, bool onOff)
- {
- // Not already in the requested state?
- if (onOff == mcFlagTstBool(itm->kind, itemDisable))
- {
- if (mcWoIsCtl(itm))
- HiliteControl(mcWoCtlHdl(itm), onOff ? 0 : 255);
-
- if (onOff)
- mcFlagClr(itm->kind, itemDisable);
- else
- mcFlagSet(itm->kind, itemDisable);
-
- SetDialogItem(mcDpPort(dp), itm->idx, itm->kind, mcWoData(itm), &itm->bounds);
- }
- }
-
-
-
- void wiValUnset(wndObj item, bool onOff)
- {
- Str63 iText;
- StringPtr title;
-
- wiTxtGetI(item, title = iText + 1);
-
- if (onOff && (iText[2] != (byte)'≈'))
- {
- iText[0] = *title + 1;
- *title = '≈';
- -- title;
- }
- else if (!onOff && (iText[2] == (byte)'≈'))
- {
- title[1] = *title - 1;
- ++ title;
- }
- else
- return;
-
- wiTxtSetI(item, title);
- }
-
-
-
- bool wiValUnget(wndObj item)
- {
- Str63 iText;
-
- wiTxtGetI(item, iText);
-
- return (iText[1] == (byte)'≈');
- }
-
-
-
- void wiTxtGetI(wndObj itm, StringPtr txt)
- {
- txt[0] = 0;
-
- if (mcWoIsCtl(itm))
- GetControlTitle(mcWoCtlHdl(itm), txt);
- else if (mcWoHasTxt(itm))
- GetDialogItemText(mcWoTxtHdl(itm), txt);
- }
-
-
-
- void wiTxtSetI(wndObj itm, StringPtr txt)
- {
- if (mcWoIsCtl(itm))
- SetControlTitle(mcWoCtlHdl(itm), txt);
- else if (mcWoHasTxt(itm))
- SetDialogItemText(mcWoTxtHdl(itm), txt);
- }
-
-
-
- void wiTxtGet(window w, ident itemID, StringPtr txt)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiTxtGetI(itm, txt);
- }
-
-
-
- void wiTxtSet(window w, ident itemID, StringPtr txt)
- {
- if (wndObj itm = wiGet(w, itemID))
- wiTxtSetI(itm, txt);
- }
-
-
-
- wndObj wiGet(window w, ident itemID)
- {
- if (PANEL tbl = mcWdTbl(w))
- {
- panel t = *tbl;
- wndObj itm = t->itm;
- int cnt = t->cnt;
-
- while(cnt--)
- if (itm->id == itemID)
- return(itm);
- else
- ++ itm;
- }
-
- return(NULL);
- }
-
-
-
-
- yError osErrorSet(yError err)
- {
- if (err)
- SysBeep(11);
- return(err);
- }
-
-
-
-
-
- #define Y_BAREBONES TRUE
-
- #include "dpVariant.c"
- #include "evModifiers.c"
- #include "mmBlkClr.c"
- #include "mmHdlCpy.c"
- #include "mmHdlExpand.c"
- #include "mmHdlWork.c"
- #include "mmPtrNew.c"
- #include "msMinimal.c"
- #include "rsFileGetOne.c"
- #include "rsGet.c"
- #include "rsNew.c"
- #include "osProcess.c"
-